/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ec.medical.controlador;

import java.io.IOException;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.apache.log4j.Logger;

/**
 *
 * @author Administrador
 */
@ManagedBean
@RequestScoped
public class LogOutControlador extends ControladorBase {

    private Logger LOG = Logger.getLogger(LogOutControlador.class.getName());

    /**
     * Creates a new instance of LogOutControlador
     */
    public LogOutControlador() {
    }
    
    public void modificacionRol() {
        try {
            ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
            ec.redirect("../../seleccionRol.xhtml");
        } catch (IOException ex) {
            imprimirLogError(" Error al desloguear " + ex);
        }
    }
    
    public void logout() {
        try {
            ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
            ec.invalidateSession();
            ec.redirect("../../../index.jsp");
        } catch (IOException ex) {
            imprimirLogError(" Error al desloguear " + ex);
        }
    }

    public void logoutSeleccionRol() {
        try {
            ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
            ec.invalidateSession();
            ec.redirect("../index.jsp");
        } catch (IOException ex) {
            imprimirLogError(" Error al desloguear " + ex);
        }
    }

    public void pantallaIngreso() {
        try {
           ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
            ec.invalidateSession();
            ec.redirect("modulos/seleccionRol.xhtml");
        } catch (IOException ex) {
            imprimirLogError(" Error al desloguear " + ex);
        }
    }
    
    public String direccionarPagina(String direccionPagina){
        limpiarDataManager();
        return direccionPagina;
    }

    @Override
    protected void imprimirLogInfo(String mensaje) {
       LOG.info(mensaje);
    }

    @Override
    protected void imprimirLogError(String mensaje) {
        LOG.error(mensaje);
    }

    @Override
    public void iniciarDatos() {
       imprimirLogInfo("iniciarDatos");
    }
}
